home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-02-21 | 7.0 KB | 213 lines | [TEXT/PJMM] |
- unit UProcessLDEF;
-
- {-------------------------------------------------------------------------------}
- {#}
- {# Apple Macintosh Developer Technical Support}
- {#}
- {# Data structures for process-list LDEF}
- {#}
- {# Program: ProcDoggie}
- {# File: ProcessLDEF.p - Pascal Implementation}
- {#}
- {# by: Forrest Tanaka}
- {#}
- {# Copyright © 1988-1991 Apple Computer, Inc.}
- {# All rights reserved.}
- {#}
- {--------------------------------------------------------------------------------}
- {#}
- {# This LDEF is a simple replacement for the standard LDEF. The only advantange}
- {# this LDEF has over the standard LDEF is that it contains information specific}
- {# to processes that aren’t displayed. This is to make identifying processes in}
- {# the Process List window easier.}
- {#}
- {# Once the icon utilities are released to the developer community, this LDEF}
- {# will be updated to display the icon of each process in the list.}
- {#}
- {-------------------------------------------------------------------------------}
- {[j=20/57/1$] Pasmat Options}
- {$R-}
-
- {-------------------------------------------------------------------------------}
- {#}
- {# 2/21/91 pvh - THINK Pascal conversion.}
- {# Notes:}
- {#}
- {-------------------------------------------------------------------------------}
-
- interface
-
-
- (*******************************************************************************}
- {* Used Units}
- {*******************************************************************************)
-
- uses
- (* Group 1 *)
- Types, QuickDraw,
-
- (* Group 2 *)
- Events, OSUtils, SegLoad, SysEqu, TextEdit, ToolUtils,
-
- (* Group 3 *)
- Files, Lists, Processes, Script;
-
-
- (*******************************************************************************}
- {* Types}
- {*******************************************************************************)
-
- type
- ProcessListInfoRec = record
- processName: Str31; {Process’s name}
- serialNumber: ProcessSerialNumber {Process’s serial number}
- end;
- ProcessListInfoPtr = ^ProcessListInfoRec;
-
-
- {$S Main}
- (*******************************************************************************}
- {* ProcessList - Entry point to the List Definition Procedure}
- {*}
- {* This is the entry point to the custom list defproc used in ProcDoggie. It}
- {* isn’t really intended to be called directly from any part of this application,}
- {* I’m just including it in the INTERFACE portion so that the linker has}
- {* something to grab onto.}
- {*******************************************************************************)
-
- procedure ProcessList (message: Integer; selectCell: Boolean; cellRect: Rect; theCell: Cell; dataOffset: Integer; dataLength: Integer; theList: ListHandle);
-
-
- implementation
-
- const
- kCellMargin = 3; {Margin between list contents and list edge in pixels}
-
-
- procedure DrawCell (cellRect: Rect; theCell: Cell; selected: Boolean; theList: ListHandle; dataOffset: Integer);
- FORWARD;
- procedure HilightCell (cellRect: Rect);
- FORWARD;
-
-
- {$S Main}
- (*******************************************************************************}
- {* Public: ProcessList}
- {*}
- {* Here’s the entry point to my custom LDEF. Yup.}
- {*******************************************************************************)
-
- procedure ProcessList (message: Integer; selectCell: Boolean; cellRect: Rect; theCell: Cell; dataOffset: Integer; dataLength: Integer; theList: ListHandle);
-
- begin
- if message = lDrawMsg then
- begin
- if dataLength > 0 then
- DrawCell(cellRect, theCell, selectCell, theList, dataOffset)
- end
- else if message = lHiliteMsg then
- HilightCell(cellRect)
- end;
-
-
- {$S Main}
- (*******************************************************************************}
- {* Private: DrawCell - Draw the contents of the specified cell}
- {*}
- {* This routine draws the contents of the cell specified by theCell into it’s}
- {* rectangle, which is specified by cellRect. In case the font is too large for}
- {* the cell rectangle, I set the clip region to cellRect before drawing the cell}
- {* text, then set it back to what it was afterwards.}
- {*}
- {* If selected is TRUE, then theCell is selected. In that case, my HilightCell}
- {* routine is called to hilight the cell.}
- {*}
- {* The list that this all takes place in is specified by theList.}
- {*******************************************************************************)
-
- procedure DrawCell (cellRect: Rect; theCell: Cell; selected: Boolean; theList: ListHandle; dataOffset: Integer);
-
- var
- cellInfo: ProcessListInfoRec; {Information for cell to be drawn}
- currClip: RgnHandle; {Handle to the current clip region}
- currPen: PenState; {Current pen characteristics}
- currFont: FontInfo; {Current font characteristics}
- dataLen: Integer; {Length of cell data in bytes}
- marginRect: Rect; {Rect that process name is drawn into}
- alignment: Integer; {Alignment of process name text}
- spareSpace: Integer; {marginRect width - text width}
-
- begin
- (* Save the current pen state and set the default pen characteristics *)
- GetPenState(currPen);(*<*)
- PenNormal;
-
- (* Save the current clip region and set it to cellRect *)
- currClip := NewRgn;
- GetClip(currClip);(*<*)
- ClipRect(cellRect);
-
- (* Will draw text into the cell rect with a margin on left and right *)
- marginRect := cellRect;
- InsetRect(marginRect, kCellMargin, 0);(*◊*)
-
- (* Get the information for the specified cell *)
- dataLen := SIZEOF(ProcessListInfoRec);
- LGetCell(Ptr(@cellInfo), dataLen, theCell, theList);(*<*)
- (*◊*)
-
- (* To find where to draw the cell’s text, get current font information *)
- GetFontInfo(currFont);(*<*)
-
- (* Position the pen for drawing the text *)
- MoveTo(marginRect.left, marginRect.top + currFont.ascent);
-
- (* Determine whether system script is left-to-right or right-to-left *)
- if GetSysJust = 0 then
- alignment := teFlushLeft
- else
- alignment := teFlushRight;
-
- (* Adjust the pen for right-aligned text if script is right-to-left *)
- if alignment = teFlushRight then
- begin
- spareSpace := marginRect.right - marginRect.left - StringWidth(cellInfo.processName);
- Move(spareSpace, 0);
- end;
-
- (* Draw the cell’s contents *)
- EraseRect(cellRect);
- DrawString(cellInfo.processName);
-
- (* If the cell is selected, hilight it *)
- if selected then
- HilightCell(cellRect);
-
- (* Restore the current clip region and pen *)
- SetClip(currClip);
- DisposeRgn(currClip);
- SetPenState(currPen);
- end;
-
-
- {$S Main}
- (*******************************************************************************}
- {* Private: HilightCell - Hilight the specified cell}
- {*}
- {* This routine hilights the cell whose rectangle is cellRect. I also clear the}
- {* hilight bit of the HiliteMode low-memory global. If this is running on a}
- {* Color QuickDraw machine, then background hilighting is done instead of}
- {* the usual inversion.}
- {*******************************************************************************)
-
- procedure HilightCell (cellRect: Rect);
-
- begin
- (* Do the fancy, new kind of hilighting on a Color QuickDraw Mac *)
- BitClr(Ptr(HiliteMode), pHiliteBit);
-
- (* Now, hilight the cell *)
- InvertRect(cellRect)
- end;
-
- end.